package com.songsf.learn.service;

import com.google.common.eventbus.EventBus;
import com.songsf.learn.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;

/**
 * Created by songsf on 2017/11/12.
 */
@Service
public class BookCache {
    public static Integer index = 0;


    @Autowired
    private AsynchService asynchService;


    @Cacheable("books")
    public Book getBook(String bookName) {

        index = index + 1;
        Book book = new Book(bookName, index);
       /* EventBus eventBus = new EventBus("log");
        eventBus.register(asynchService);
        eventBus.post(book);*/
        return book;
    }
    @Cacheable("names")
    public String getName(String name){
        System.out.println("111111111111111111111111111111");
        return "new"+name;
    }
}
